home *** CD-ROM | disk | FTP | other *** search
/ Resource for Source: C/C++ / Resource for Source - C-C++.iso / misc_src / qcard2 / form1.frm (.txt) < prev    next >
Visual Basic Form  |  1995-11-01  |  18KB  |  358 lines

  1. Form1
  2. QCard.DLL Demo
  3. Form1%
  4. Timer1
  5. Dra&wing
  6. DrawCard
  7.     Draw&Card
  8. DealCard
  9.     &DealCard
  10. DrawBack
  11.     Draw&Back
  12. DrawSymbol
  13. Draw&Symbol
  14. RemoveCard
  15. &RemoveCard
  16. MenuExit
  17. E&xit
  18. Information
  19. &Information
  20. CardInformation
  21. &CardInformation
  22. Dragging
  23.     &Dragging
  24. MenuDoDrag
  25. D&oDrag
  26. MenuHelp
  27. &Help
  28. m    MenuHowTo
  29. Ho&w To...
  30. n    MenuAbout
  31. A&bout
  32. Form_Click
  33. DealCard
  34. Form1
  35.     Form_Loadi
  36. InitializeDecke
  37. Form_MouseDown
  38. Buttons
  39. Shift
  40. View_Click
  41. DealCard_Click
  42. DrawBack_Click(
  43. DrawBack~
  44. MenuExit_Click
  45. DrawSymbol_Click
  46. DrawSymbol
  47. EraseCard_Click
  48. DrawCard&
  49. Timer1
  50. EnabledE
  51. TRUEr
  52. Timer1_TimerA
  53.     EraseCard
  54. FALSEC
  55.     CARDWIDTHu
  56. CARDHEIGHT
  57. DrawCard_Click
  58. RemoveCard
  59. RemoveCard_Click.
  60. CardInformation_ClickY
  61.     bDragging
  62. Form_MouseMove[
  63. Form_MouseUpq
  64. GetCardColorQ
  65. GetCardValue
  66. GetCardSuit
  67. GetCardX|
  68. GetCardY
  69. IsCardVisible
  70. Width2
  71. Height
  72.     ScaleMode
  73. ScaleTop
  74.     ScaleLeft
  75. Information_Click
  76. ScaleWidth
  77. ScaleHeight>
  78.     bDragDemo
  79. SPACER
  80. MenuDoDrag_Click
  81. AdjustCardBlocked
  82. ActiveCard
  83. PointInCard
  84. nActiveCardH
  85. SetActiveCard
  86. InitDrag
  87. DoDrag)
  88. EndDrag
  89. OldY5
  90. Dragging_Click
  91. ReturnDrag
  92. PointInFreeCard
  93. Screen#
  94. MousePointer.
  95. InitDeck
  96. Form_Paint
  97. SetCardDisabled,
  98. Picture1
  99. nReturn
  100. PointInCardTop~
  101. Form_DblClick
  102. nClickedCard
  103. GlobalXf
  104. GlobalY
  105. DblClkX[
  106.     DblClickX
  107.     DblClickY
  108. nSpacer
  109. OFFSET
  110. BlockCardsf
  111.     BlockDrag
  112. OffsetX
  113. OffsetY
  114. EndBlockDrag
  115. bSingleDraggingc
  116. bBlockDragging
  117. bBlockDrag
  118. SetDefaultValues
  119. ReturnBlockDragr
  120.     DragCardsN
  121. Form2
  122. upperbound!
  123. lowerbound
  124. Lefte
  125. fresh
  126. GetFreeDestination
  127. GetCardBlocked
  128. nEndDrag
  129. nTemp
  130.     AbortDrag
  131. nSourceCard
  132.     nDestCard9
  133.     CardArray
  134. Counter
  135. cxSpacer|
  136. SetUser3
  137. SetUser4
  138. nStatus
  139. nArrayID
  140.     nArrayPos
  141. nItems'
  142. GetUser4
  143. GetUser3+
  144. nNewXD
  145. nNewY
  146. nSourceArrayV
  147. nSourceArrayPosq
  148. nDestArray
  149. nSourceColor
  150. nDestColor
  151. o_Click
  152. nSourceArrayID
  153. nDestArrayID
  154. nDeltaX
  155. nDeltaY
  156. nSourceX|
  157. nSourceY
  158. nUnused
  159. SetCardBlocked
  160.     dlbClickY
  161.     DlbClickX
  162. nThisSourceCard
  163. nThisDestCard
  164. bMouseMoved7
  165. process
  166. clicks
  167. similarR
  168. MenuHowTo_Click
  169. Helpn
  170. MenuAbout_Click
  171. About
  172. AutoRedraw
  173. nDrawSelection
  174. SelectCase
  175. nInformationCard
  176. DoText        
  177. nCard
  178. MenuHelp_Click
  179. GetCardStatus
  180. SetCurrentBack
  181. SetCardStatus
  182. FACEDOWN
  183. FACEUP
  184.  This program demonstrates some of the function callss
  185.  of QCard.DLL. In an effort to keep all code under
  186.  their respective Event Procedures, I have not usedd
  187.  any Sub procedures of my own. Using a few Sub proceduress
  188.  would considerably clean up the "spaghetti" nature of
  189.  some of the dragging events.t
  190.  This demo is not complete in that it does not repaint
  191.  it's window properly. I was more interested in demonsrating
  192.  function calls rather than creating a usable product.
  193.  declare a few counters 
  194.  declare some test switchesn
  195.  declare some card identifiers
  196.  to save mouse position for double click event
  197.  set up a two dimensional arrayy
  198.  four arrays to hold the numbers of thee
  199.  cards in each piled
  200.  set up a counter to go along with each pile
  201. CardInformation_Click
  202.  pick a random cardi
  203.  pick a random locationt
  204. Int((upperbound - lowerbound + 1) * Rnd + lowerbound))
  205.  set current information card for Paint eventt
  206.  deal the card
  207.  draw in the text informationr
  208. DealCard_Click
  209.  deal cards in a diagonal line
  210. DoText
  211. Card number is 
  212. Card color is 
  213. Card value is 
  214. Card suit is 
  215. Card x location is 
  216. Card y location is 
  217. Card Status value is 
  218. Form ScaleWidth is 
  219. Form ScaleHeight is 
  220. DrawBack_Click
  221.  draw six piles of cards offsetting by 2 pixels up and overr
  222. DrawCard_Click
  223.  draw the cards using DrawCard
  224.  this does not update any of the propertiess
  225.  of the cardst
  226. DrawSymbol_Click
  227.  draw in one of each of the three symbolss
  228. Form_DblClick
  229.  Only process DblClick in Drag Demo 
  230.  You can process double clicks in a similar
  231.  way to the ButtonUp event.c
  232.  The current mouse position is saved for us in the
  233.  ButtonDown event as DblClickX and DblClickY
  234.  Instead of using the Shared variables nSourceCard
  235.  and nDestCard, we will use two local variabless
  236.  nThisSourceCard and nThisDestCard..
  237.  We need to do this because VB processes ButtonDownn
  238.  and ButtonUp messages before it actually gets too
  239.  the DblClick event. This will keep our currentt
  240.  selections from being corrupted by one of the
  241.  other eventsr
  242.  We can use the PointInFreeCard function to determinee
  243.  if the mouse is within any card that is not blocked
  244.  pick a destination pile according to original pileE
  245.  if this is the last card in a row, and not the only card in the row
  246.  then move it over to the other "same color row" and adjust arrays and blocks
  247. Form_Load
  248.  try to fire up the DLLL
  249.  a FALSE return value indicates problems
  250. Sorry. Another application is using QCards.DLL
  251.  set ScaleMode to Pixel(3) so form and DLL use the
  252.  same coordinatess
  253.  make form full screen width
  254.  make some initial assigns
  255. Form_MouseDown
  256.  InitDrag returns the number of the card that contains the
  257.  mouse, as well as setting up the drag operation
  258.  save mouse x and y position for double click eventt
  259.  no card selecteds
  260.  save old position for later use
  261.  if the drag is invalidh
  262.  if card is not blocked, it is a single drag
  263.  if it's blocked, it means were doing a block drag
  264. Form_MouseMove
  265.  if just a single card, it's number was set with InitDrag call
  266.  determine which pile we are dealing withr
  267.  determine the position of the first card in dragn
  268.  how many cards are we movinge
  269.  create an array to hold the numbers of the cards to movee
  270.  and fill the array starting at 0e
  271.  pass the BlockDrag sub the actual array, referencing it's
  272.  first element. This acts as a "pointer" to the rest ofs
  273.  the elements in the array in memory
  274.  let the MouseUp event know that it is ok to
  275.  reference the Temp(0) array for this instance
  276. Form_MouseUp
  277.  most of the code here involves relocating cards
  278.  to their new homes/arrays
  279.  end the drag operation and
  280.  find out who we are dropping in on
  281.  do some color testing
  282.  only allow drop if source and destination colors are the same
  283.  and if nSourceCard is not the last card in it's pile.
  284.  if nDestCard is 0, the Source Card was dropped at an invalid location
  285.  if not a valid drop site, return drag
  286.  valid single drag/drop... proceed with relocation
  287.  which array did we come fromt
  288.  reduce our old array countert
  289.  which array are we joining
  290.  add another to it's counter
  291.  block our new neighbor
  292.  install our new arrayID and positiong
  293.  align with left side of card above us
  294.  and down OFFSET (16)o
  295.  unblock last card in old array
  296.  add ourselves to new arrayr
  297.  we can reuse the Temp() array from MouseMovee
  298.  as long as MouseMove actually occurredc
  299.  end the drag and find out the destination card
  300.  do some color testing
  301.  only allow drop if source and destination colors are the same
  302.  and nSourceCard is not the last card in it's pile
  303.  if not a valid drop site, return drag
  304.  which array did we come from
  305.  reduce our old array counter
  306.  which array are we joining
  307.  block our new neighbor
  308.  this bit of code demonstrates how you can "fool" a drag operation
  309.  to drag the item to a specific location. Usually, you pass the 
  310.  BlockDrag sub the x,y location of the mouse. If you first determine
  311.  your current mouse position in relation to the object you are dragging 
  312.  you can add that difference (nDeltaX, nDeltaY) to the position youi
  313.  want to drag to, and pass those points to BlockDrag. We want to align
  314.  with the left side of DestCard and down OFFSET (16) pixels from its top
  315.  install our new arrayIDs and positionsn
  316.  unblock last card in old arrayy
  317.  remove temporary block on last card in block drag array
  318.  There was a MouseDown event but no MouseMove evente
  319. Form_Paint
  320.  Even when the AutoRedraw property for yourr
  321.  form is set to TRUE, VB will not redraw any
  322.  of your cards for you. You must handle thee
  323.  redrawing in the Paint Event. In a normal cardd
  324.  game, your Paint Event will look a lot like
  325.  Case 6 beloww
  326. MenuAbout_Click
  327. Form1.Refreshh
  328. MenuDoDrag_Click
  329.  clear out any old card properties
  330.  draw in symbols
  331.  each pile has it's own array identifying the cardss
  332.  each pile has a counter to maintain the pilee
  333.  each card uses it's User3 and User4 properties to
  334.  store which array it belongs to and what position
  335.  it's in within the array. This makes dragging and
  336.  dropping easier
  337.  deal first pile and set up array
  338.  card's position in array
  339.  array ID 
  340.  block all cards except the one on top
  341.  there are 13 cards per pile
  342.  card's position in array
  343.  array IDc
  344.  card's position in array
  345.  array IDc
  346.  card's position in array
  347.  array IDc
  348. MenuExit_Click
  349. MenuHowTo_Click
  350. winhelp.exe 
  351. \qcard.hlp
  352. RemoveCard_Click
  353.  deal 13 cards and enable the timer sub which will remove them
  354. Timer1_Timer
  355.  remove cards one at a timee
  356.  don't forget to take them off in reverse orderr
  357.  or you will have a mess
  358.